﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

using AttributeRouting;
using AttributeRouting.Web.Mvc;
using Newtonsoft.Json.Linq;
using Phatent.Model.Results;
using Phatent.Model.Pages;
using Phatent.Logic.Pages;
namespace Phatent.Website.Areas.Home.Controllers
{
    [RouteArea("Home")]
    public class GeneralApiController : ApiController
    {
        [Route("GetPages")]
        [HttpPost]
        public JsonEntitySet<PageModel> GetPages(JObject request)
        {
            string errinfo = "no data";
            try
            {
                PageQuery sea = new PageQuery();
                sea.PageIndex = request.Value<int>("pageIndex");
                sea.PageSize = request.Value<int>("pageSize");
                sea.CaseID = request.Value<int>("caseID");
                sea.Visible = request.Value<bool?>("visible");
                var result = PageLogic.Gets(sea);
                return new JsonEntitySet<PageModel>(result);
            }
            catch (Exception ex)
            {
                errinfo = ex.Message;
                //Common.Logger.Error("", ex);
            }
            return new JsonEntitySet<PageModel>(null, errinfo, false);
        }

        
    }
}
